Fixed 'undefined offset' error.
Merge pull request #2 from andygock/master

Fixed undefined offset error.