replace lambda with named function