first pass refactoring without testing