adapted to postgres