Fixed update logic when inserting new node.