added null guards

just the usual :wink: