thanks, fixing that up. doing the length upfront has a very marginal perf improvement, however we are micro-optimising here so we might as well go the whole way