Move logic from controller to service