personal R functions