Check for null

Avoids NullPointerException
Merge pull request #41 from mikegr/patch-1

Check for null