//todo: this method is overly complex due to the nature of how rules are stored. with time try to refactor this private KeyValuePair <Name, HashSet <AppraisalRule> > findExistingAppraisalRule(Guid id, out AppraisalRule rule) { foreach (var ruleNamePair in Rules) { var ruleSet = ruleNamePair.Value; foreach (var appraisalRule in ruleSet) { if (appraisalRule.Id == id) { rule = appraisalRule; return(ruleNamePair); } } } rule = null; return(Rules.FirstOrDefault()); }