fix average calculations.