Fix can't read length of undefined error.
Merge pull request #1 from keighty/fix_length_error

Fix can't read length of undefined error.