replace deprecated delete with destroy()