Added comments to both functions explaining what they do.