Added extra null check

As the title says.

Somehow I also see that my previous PR wasn't merged. The one about 'fixed adding the 'required' property', as these changes show up in this PR again.