optimize code
bug fix