debug refactoring