Small refactoring to the switch directive