Caching next element prior to current loop finishing could result in race condition