added some comments to larger functions