change the destruction function to virtual