first pass refactoring