Fixed testing for null, undefined per comments from @jochenberger