Moved AR testing from using global variable to thread variable