Refactoring server.js 2