Moved the business logic from the controller to the service.