Added all the comment lines to explain what each line of code does.