converted service to a class to be able to use it as a library too