move debug function into utils