move code into service module