fix for handling IndexOutOfBoundsException
Merge pull request #486 from agdula/master

fix for handling IndexOutOfBoundsException