Move repeating code to the service.