update if-else to switch statement