Refactoring server.js