Updated .R file