added a bit more debug code