changed 2 functions to data frame