added comments to explain what the script actually does