buffer handling improved