Updated stats function