fixed endless loop on multiple buffers