Refactoring set_debug function.