Bring query out to global var