fix potential null pointer issue.