I have seen this match block somewhere else in the code ;) maybe factor it out?