Used a switch instead of if-else