update stats avg sample code