Fixed calculation of total