fix the query selection