added comments to code to explain what each piece of the code does