Changed x1,x2,y1,y2 to global variables