More defensive error checking on matches