updated for postgresql