Fixed debug function