fix bug on memory buffer