Refactored to use Command pattern