fix null pointer dereference