much of refactoring