silly refactor
there must be a way to store the result of the match, but it's a hack