fix null pointer issue in if print