implemented tot_average