minor changes to R code