using typeof instead of comparing to "undefined" variable