move stuff out of api into service