place null testing before first use
Merge pull request #1067 from bigsfr/master

place null testing before first use