Use subsetting instead of range looping