Refactor if cases to case statements