added some comments to javascript code