Added comments to all functions