Fixing update_totals bug