fix buf closing