adapting code to use service locator