added comments to explain objective in js file