isn't this `takeWithin(d).grouped(n)`?