Fixing query encoding