major refactoring finished