Add NULL pointer check.