defined how to update the averages.