changes to R code