partially done refactoring