major refactoring and restucture