pass functors by reference