before querythread check