done major refactoring