refactoring server.js