while (bytesToRemove > 0) {
// does tailing buffers exits?
if (writePosition < bufs.size()) {
ByteBuffer buf = bufs.remove(writePosition);
if (buf.remaining() > bytesToRemove) {
buf.position(buf.position() + bytesToRemove);
bufs.add(writePosition, buf);
} else {
bytesToRemove -= buf.remaining();
}