Could you factor this match out into a separate method? It's fairly long.