Extracted nodeCheck into seperate function
Improved documentation and readability