Moved updateXY to separate file