rewrite app.js to long polling of #1