refactor port stuff in app.js