Detect null pointer, avoid crash