fixed another NULL pointer crash in the same function (see previous commit)