Added null pointer check.
Merge pull request #59 from redboltz/add_null_check

Added null pointer check.