Fixed bug in fill_buffer