Refactor switch into something more readable