changed long if-else to switch statement)