Slightly cleaner logic using case statement