refactored code to do the custom debug log better