Partially refactor case statement