refactored controller logic into a manager class