Added additional comments to explain variables and functions