Refactor exact_match_count, using inject and ternary operation