man this seems nasty. There has to be a better way to compose this whole logic/switch.