updated for use with couchdb instead of cloudant