Fix bug in match logic.