refactored code to avoid ovelapping Nodes