fix null pointer issue