Fixing query issue