fix to_buffer