Changed transfn and finalfn to per group