Refactor the addr_eq function