Moved check to run only if $node exists.