subsetting dimensions before calculations (iterating)