improve bufferhandling