removed hasOwnProperty and added type checking