more bug fixed and more optimization