Refactor switch