fix bug in mem