issue 29 and add debug code