add debug code before leaving