[p5js] fix errors

//let's find and fix errors

var moving = false;
var x1, y1, x2, y2;

function setup() {

  createCanvas(400, 400);
  noFill();
 strokeWeight(5);
}

function draw() {
  background(235); 
  rect(x1, y1, x2, y2); //draw once 
}

function mousePressed() {
  if (x1 < mouseX < x2 && y1 < mouseY < y2) {
    moving = true;
  }
  else{  
  x1 = mouseX
  y1 = mouseY
  }
}

function mouseDragged() {

  if (moving == true) {
    x1 = x1 + (mouseX - pmouseX);
    y1 = y1 + (mouseY - pmouseY);
    x2 = x2 + (mouseX - pmouseX);
    y2 = y2 + (mouseY - pmouseY);
  } else{
    x2 = mouseX - x1
    y2 = mouseY - y1
  }
}


function mouseReleased() {
  
   x2 = mouseX - x1
    y2 = mouseY - y1

}