Converting if to switch