made tentative changes to R code