further code for buffer management