updated doReplay loop