Fixed null pointer dereference