Unit Switching - Code Refactored