fix null dereference issue