new code to remove duplicated pairs in skeleton