added some comments to document functions