refactored debug mode
refactored debug mode