checking with == undefined instead of !