# Running EBM model in a function

**URL:** <https://discourse.julialang.org/t/running-ebm-model-in-a-function/117512>\
**Category:** Modelling & Simulations\
**Tags:** agents, modelling, eventqueueabm\
**Created:** [July 26, 2024, 1:18pm UTC](https://discourse.julialang.org/t/running-ebm-model-in-a-function/117512 "2024-07-26T13:18:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [July 26, 2024, 1:18pm UTC](https://discourse.julialang.org/t/running-ebm-model-in-a-function/117512/1 "2024-07-26T13:18:19Z")

</div>

Hello everyone,

Im running EBM model inside a function which is causing issue with calling model properties values. Is there a way to extract them inside function?

General Idea of my function:

```julia
model = model_initiate()

function test_run()
   for i in 1:10
    mm = i # its a model property                                                
                                 #that I want to chnage in                                                                        
                                 # every iteration 
     model = model_initiate() # And thats why I                                    
                                   # repeat initialisation
     run!(model, steps)
     println(model.xx)
   end
end

```

now problem is this `model.xx` is different if I print outside of function. Basically what is happening is run updates global model while this local model stay at initial value. Is there a way to update local model when I run model?

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [July 29, 2024, 9:28am UTC](https://discourse.julialang.org/t/running-ebm-model-in-a-function/117512/2 "2024-07-29T09:28:25Z")

</div>

As usual, please provide a _complete_ MWE, _full_ stacktrace, and a _proper_ description of your experienced issue and the expected behaviour.
