fix a panic if index out of range
Merge pull request #2 from umisama/patch-2

fix a panic if index out of range