this list comp will be much faster with the ``set`` comprehension for the construction of ``selected_ids``.