Reduce duplication of stats logic

removed the duplication of the stats logic