avoid undefined array index
Merge pull request #3 from tmm1/fix-errors

Avoid undefined array index