Dog_matches_controller refactored to:

* remove duplicated code and simplify conditional expression
* by moving repeated logic out of the conditional