fix consensus.js to be more robust