add some protections for null pointers