comments added
Outputs correct answer at the end of the file.