Callback error updating overview-filtered.figure

Getting the following error message in my debug:

Callback error updating overview-filtered.figure

UnboundLocalError: local variable ‘fig’ referenced before assignment

Traceback (most recent call last):
  File "C:\Users\name\Code\Project\", line 282, in create_overview_filtered
    fig2 = px.line(
  File "C:\Users\name\Code\Project\venv\Lib\site-packages\plotly\express\", line 260, in line
    return make_figure(args=locals(), constructor=go.Scatter)
  File "C:\Users\name\Code\Project\venv\Lib\site-packages\plotly\express\", line 2170, in make_figure
    fig = init_figure(
  File "C:\Users\name\Code\Project\venv\Lib\site-packages\plotly\express\", line 2315, in init_figure
    for annot in fig.layout.annotations:
UnboundLocalError: local variable 'fig' referenced before assignment

Here’s the snippet of my callback portion

def create_overview_filtered(selected_sim, selected_time):

    next_event = df_sessions[

                        (df_sessions.SimId == selected_sim) & 

                        (df_sessions.SimulationTime > selected_time)]['SimulationTime'].min()

    dff_ts = df_ts[

                (df_ts.SimId == selected_sim) &

                (df_ts.SimulationTime >= selected_time) &

                (df_ts.SimulationTime < next_event) &


    fig2 = px.line(


                x = 'SimulationTime',

                y = 'Value',

                color = 'Attribute', 







        yaxis = dict(title='Value'),

        title = dict(text='Vitals overview until next event'),

        hovermode = 'x'


    return fig2

Edit1: I have other callbacks prior to that but im not sure why it means local variable ‘fig’ if in that function I dont have any fig variables. FYI line 282 starts at fig2 where px.line is being populated