updated this excercise with inline comments explaining the program in it's etirety