statistics refactoring