moved specific implementation of stats service to be more generic for future use