Code works!

Working code. Now the code needs comments to explain how it works.