fix bugs, optimize speed works