Make api more consistent, take reference to function