changed R code