Fixed (with a hack) the computation of the average