fix the NULL pointer issue