Rewritw complex if-statement to a switch statement.