improve merge_and_remove_duplicate