added queryAndSort
added queryAndSort