I hate being off by one. It happens a lot with loops and I had it happen again today.
for(int i=0; i < payments.length-1; i++)
length is not zero based so I need to loop from 0 to length not inclusive. However I was one short.
The fix was simple.
for(int i=0; i < payments.length; i++)