added modified version of smoke's debug script