Added ability to pass functions directly