speeded up the destructor function