corrected calc of totals