Although this function only runs on the main thread, it seems safer to clear the flag only after setting the result.