moved some code to the service class