get stats function