added comments to code

for understanding