refactored and added debug toggler