mapply function. still needs work.