bug fix and test