Changed case statement to if