Refactoring subsetting logic.