removed duplicates and orphan nodes