Code refactoring for Stats class