use simple buffer instead of linked list