Fixed $nodetype while loop