first pass refactor