A more efficient algorithm for remove-duplicates on lists when there