refactor and export get_address_type()