Added comments to each function