refactoring on paper, untested