Fixed the memory map function