updating stats function