converted to pg from sqlite3