improve query order/historder