factor out cv port writing