changed if-else to switch-case