fix null ref issue