start of major refactoring