fixing bug with add memory