bug fix and improvement