refactoring partially done