fix a nil pointer bug