Changed if-else to switch-case