final major refactoring