Changed logic for totals