case statement refactoring