Fixed delete function