Merge pull request #62 from ilgrosso/ARRAY_INDEX_OUT_OF_BOUNDS

Checking array size before access to avoid ArrayIndexOutOfBoundsException