If I understand your question well, you should keep the
coordinates in variables, then get the new coordinates for the
test, do the test and only keep the new coordinates if the test
fails, if the test returns true then set your coordinates to the
old ones you kept in variables.