function to update stats