Revised R code and results