add snippet for cached length loop