updated to work with postgres 8.4