refactor server.js a little bit