Change switch statement to if else