major refactoring