fix potential NULL Pointer issue.