Add null pointer check
Merge pull request #192 from oberd/master

Null Pointer Exception