Updated the memory allocation process