code clean and bug fix