move logic from controller to service