Updated R functions