added function to postgres