fix query encoding bug, for #6