tweaked debug code