Sample code tried from Professional Node.js book by Pedro Teixeira