Use the length of the cache instead of the constant