Change if statement to case statement