grouping ID's to remove duplicates