fix replica loop