script clean up and integrated in rstudio