done some structural refactoring