Added comments to explain functions