added sort to query