corrected null check