Get rid of the ugly switch statements