Converted if-else to switch