modified postgres cookbook