changed hasOwnProperty to typeof