update function calc_average