fix null-ptr error