move cache replay into 'main loop' to stop cache race