added some comments into server.js
refactoring a little bit