added order_by given field to solve trouble with DISTINCT ON statement