refactored debug module