refactor the destructor