Extract users query logic from the controller to the service layer