added comments to elaborate code