fixed possible null pointer dereference