Passing functions to spark