Refactor to use subsetting