modified to support postgress