Moved declaration of nodes out of for loop.