Fixed a null pointer issue