solution 1 revised 2

Even more comments added and formatted.