add comments to understand functions