Replaced if/else chain with a switch