Improve the NULL check