tweaked for postgres updates