Add debug code for debug mode