Added a null check

This is in addition to the undefined check