improve some function and modify some bug