transformed_list and transformed_set are almost identical, most of the code should be factored out to one common file