added comments to js functions