some bugs and debug code are removed