organizeNodes: make it more readable