Added a few more comments to describe the code