Use case statement instead of if statement