Added totals and afterChange logic