change from != null to typeof !== 'undefined'