Replaced duplications with loop