if else chain changed to a switch