removed ORDER BY from SELECT statements for Postgres compatibility