consolidated vote and publish functions in main.js to be a single function