tried to fix some bugs,but not done.