TheOraware:

Interesting thing is when i increase it by 23 it does not give error


This could mean that the max. index is larger than you expect, so you could add assert statements to your code to narrow down the largest values.