change private function in controller to service