Fixing Query Bugs and NameErrors
Fixing Query Bugs and NameErrors