Fix naming bug in loop