added the loadDataToMem function