improve stats generation