Add a necessary null check and Remove unnecessary null checks.