Added a destructor to deallocate memory when program ends