rewrite to use postgresql beta2