debug refactor