Please use ``null ===`` to check for null for consistency with the coding standards.

And please move it before the loop