Fixing iteration issue in part 2
Stops replacement when there is a conflict