fixed bug with query encoding