adapted refactoring