R code updated