Use switch rather than if

Also remove debugging statement.