Added comments to explain code and variables