Fix loop count