updated nodeid gathering logic