Refactor server.js