fixed an infinite loop when number of repeats was a multiple of 0xFFF