Fixing query stuff