Deduplicate ID list reading code