Refactored switch