fixed R code