refactor, first pass