Changing the memory to dynamic memory allocation