started major refactoring