changed if statement to case statement