change switch statement to if clauses