Pulled out code from the controller and put it into the user service