moved debug code