refactoring collapse