Typo fix and null pointer check