extract functionalities from controller to service