half way through refactoring