fix subsetting to solve duplicate issue