converted if to switch