added functions.R