Fixed null pointer issue