fixed null pointer dereference