You are going out of bounds in the for in line 43. I guess you are computing variable len incorrectly.