Fixing Query issues