changes to insert and modify in the same loop, should speed things.