small imprrovement in the destroy function