improve get_master_domain