rewrite from if statement to case statement.