added stats function