added some comments to the functions