refactor statistics