fixed bug with order of hash and query