adding totals; updated sorting