move code to service