using hasOwnProperty in object loops