buffer close bug fix