buffer bug fix