towards a cleaner R script