converted to postgres syntax. Not yet tested