bug fix and small improvement