refactors and comments server.js