server.js: refactoring