Refactored matching for sanity

I'd like to do more types of matches, so this is a little more
straightforward.