Check lengths in replaceNodes