There is already several places in the code identical to this, including new additions to this CL: factor out into a function?