Started WriteToMemory function