modified to alleviate potential problem using a variable named R_PATH
reordered file