redesign function in publish.js