Completed the requirement dealing with memory management and dynamic variables