updated debug function.