Added comments to help explain the code