cleaning up R script