Correct duplicate definitions in loop