Correct bug in node deletion logic