fix querying of orders. still stuff to do...