         
         let lambda = parameters[3]
         
-        let f: (SExpr)->SExpr = { params in
+        let f: (SExpr, [SExpr]?, [SExpr]?)->SExpr = { params,locals,values in
             guard case var .List(p) = params else {return .List([])}
             p = Array(p.dropFirst(1))
             
             // Replace parameters in the lambda with values
-            if let result = lambda.replace(this:vars, with:p).eval(){
+            if let result = lambda.eval(with:vars, for:p){
                 return result
             }else{
                 return .List([])

        return .Atom(fname)
    }
    //List implemented as a classic builtin instead of a series of cons
    env[Builtins.list.rawValue] = { params in
        guard case let .List(parameters) = params, parameters.count > 1 else {return .List([])}
        var res: [SExpr] = []
        

            // Evaluate all subexpressions
            if !skip {
                elements = elements.map{
                    return $0.eval(with:locals, for:values)!
                }
            }
            node = .List(elements)
            
            // Obtain a a reference to the function represented by the first atom and apply it, local definitions shadow global ones
            if elements.count > 0, case let .Atom(value) = elements[0], let f = localContext[value] ?? defaultEnvironment[value] {
                let r = f(node,locals,values)
                return r
            }
            
