refactor server.js