add some comments to clarify some points of the R code