refactor to use a service