Improved updateXY() method