Rework - allows for arbitrary function and vars