updated the way script finds last saved ledger in couchdb