you can do something so much shorter..
if ( $2 == $null ) {
not only can it be ($2 == $null), but it can be
if (!$2) {