Prevented TypeError where variable was null
Merge pull request #4 from rogst/master

Fixed TypeErrors trying to access null variable