Fix bug when matching data for building research subsets