swapped switch for if else