Replace switch with only one case with if statement