working R code has been added