use hasOwnProperty instead of typeof !== 'undefined'