fix NULL pointer bug