bug fix and code clean