improve the performance and revise some bugs