added R functions