refactor app.js and config