stats refactoring