changed to pg_query