Adding the memory code