made global variables x2 and y2 reference parameters