refactor into a statistics service