added some inline comments to provide some clarity.