Drawing array of curves from PVector

Adding this at the end of for loop in void present(0

this.history.remove(i-1)

Helps, but it creates separated lines one by one.

I am trying to create a vertex insted, but I cannot create vertex with history.remove(i-1)…

I tried using lerp as well, but this did not help

    noFill();
    beginShape();
    for(int i = 2; i < this.history.size(); i++) {
      //PVector p1 = this.history.get(i - 1);
      PVector p1 = this.history.get(i-1);
      PVector p2 = this.history.get(i);
      float x = lerp(p1.x, p2.x, 1);
      float y = lerp(p1.y, p2.y, 1);
      vertex(x,y);
      //this.history.remove(i-1); //remove previous origin
    }
    endShape();