debug function reworked