fix the index out of bound bug

I have fixed the bug which leads to index out of bound, now you can successfully run 12-test