[Fact] refactorize code for statistics module