Replace hasOwnProperty checks with hasKey