Added comments to the major functions