public IEnumerable <ReturnModel> FindMatches(string text, User user) { _auditWriter.LogUserCall(user); var matches = new List <ReturnModel>(); foreach (var w in text.Split(" ")) { var word = w.RemovePunctuationAndSymbols(); var match = _badWordCache.Words.FirstOrDefault(x => CheckForMatch(x, word)); if (match == null) { continue; } _auditWriter.WriteToAudit(match.WordId); var alreadyFoundMatch = matches.FirstOrDefault(x => x.Word.Equals(word, StringComparison.CurrentCultureIgnoreCase)); if (alreadyFoundMatch != null) { var item = matches.Single(x => x.Word.Equals(word, StringComparison.CurrentCultureIgnoreCase)); item.Occurrences += 1; continue; } matches.Add(new ReturnModel { Word = word.ToLower(), WordTypeId = match.WordTypeId, WordType = Enum.GetName(typeof(StaticData.WordType), match.WordTypeId), Severity = match.Severity, Occurrences = 1, }); } return(matches); }