I have a problem with my cells where I remove/insert to my `tableView`, I delete and insert my cells like that : 

```
self.tableView.beginUpdates()
user.lobbySurvey.remove(at: 0)
self.tableView.deleteRows(at: [IndexPath(row: 0, section: 0)], with: .fade)
self.tableView.endUpdates()

```

Insert: 

```
self.tableView.beginUpdates()
user.lobbySurvey.insert(surveyEnded, at: rowToInsert)
self.tableView.insertRows(at: [IndexPath(row: rowToInsert, section: 0)], with: .fade)
self.tableView.endUpdates()

```

`lobbySurvey` is the data array of the TableView.
Problem is the cell I add keep the design of the first cell that I delete previously.

I think this issue is because I check if the card is draw or not. If not checked: the view of the card is added each time the cell is reuse.
this is how I check if the cell is draw or not :

```
func drawSurveyEnded(){
    if(cardIsDraw == false){
        surveyEnded.draw(cardView: self.cardView)
        surveyEnded.delegate = self
        self.addCardShadow()
        cardIsDraw = true
    }
}

```

The function is called many times cause to the reuse system of iOS. So I think my problem come from here.

Why my cell in my tableView keep the design of the previous cell that I deleted?

**Other code :** 

```
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:"Celll") as! CardCell
for survey in user.lobbySurvey{
    let index = user.lobbySurvey.index(where: {
        //get the current index is nedeed else the cells reuse lazy
        $0 === survey
    })
    if indexPath.row == index{
        var surveyState : UserSurvey.state
        surveyState = survey.state
        switch surveyState{
        case .selectSurvey:
            cell.drawCard(statutOfCard: .selectSurvey)
        case .goSurvey:
            cell.drawCard(statutOfCard: .goSurvey(picture: survey.picture))
        case .surveyEnded:
            cell.drawCard(statutOfCard: .surveyEnded(picture: survey.picture))
        case .surveyWork:
            print("survey in progress to vote")
        case .surveyWaiting:
            cell.drawCard(statutOfCard: .surveyWaiting(selfSurveyId: survey.id, timeLeft: survey.timeLeft, picture: survey.picture))
        case .buyStack:
            cell.drawCard(statutOfCard: .buyStack(supView : self.view))
        }
    }
}

cell.delegate = self
cell.delegateCard = self
cell.layer.backgroundColor = UIColor.clear.cgColor
cell.backgroundColor = .clear
tableView.backgroundColor = .clear
tableView.layer.backgroundColor = UIColor.clear.cgColor
return cell
}

```

Draw card is a simple switch of the state of the survey where called the good function to create the card like this one I posted before : `drawSurveyEnded`