add some comments to the code
some modification