added a few comments to make things clear