Refactored operation switch with factory pattern