Rewrite the if-else to switch