fix null pointer deref