Refactored to switch