fix some bugs,but need unit test