fixed null pointer dereference bug