edited delete function`