Advice on using hasOwnProperty