updated the R code only