Added some comments as per my professor's expectations.