fix order of nodes to be removed