move helper functions to service