fix some bugs add some comments