Added comments to the sections in order to understand train of thought