cleanup R code