added some comments to the function definition