Replace a switch with an array lookup