added debug code
fixed typo in debug code