begin major refactoring