update stats averaging sample code