changed code to reorder index when items are removed