first pass at refactoring done