Add a null pointer guard