move function to service