small refactoring of node.js code