refactor read2Mem