added comments to describe what things do