this is essentially a refactoring: there's no behavior change. but it'll help later part of this branch.