completed postgres implementation