Fixed nil pointer check.