Updated R file