# Cannot use Self before Self has been defined

**URL:** <https://forum.dfinity.org/t/cannot-use-self-before-self-has-been-defined/25933>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [December 27, 2023, 5:25pm UTC](https://forum.dfinity.org/t/cannot-use-self-before-self-has-been-defined/25933 "2023-12-27T17:25:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesbeadle](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jamesbeadle/32/10110_2.png) [@jamesbeadle](https://forum.dfinity.org/u/jamesbeadle)\
**Post date:** [December 27, 2023, 5:25pm UTC](https://forum.dfinity.org/t/cannot-use-self-before-self-has-been-defined/25933/1 "2023-12-27T17:25:10Z")

</div>

Hello,

I am trying to reference the treasury account of OpenFPL for topping up the cycles wallet but I have the following error:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/0/03aa51042cc40c1368082c6dda0df78b65d17733.png)

So on footballgod (another app I use) I do the same thing but have no problem referencing Self.

Any help greatly appreciated, here is the link to the file:

> <https://github.com/jamesbeadle/OpenFPL/blob/master/src/OpenFPL_backend/main.mo>

---

<div class="post-metadata">

**Author:** ![rossberg](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rossberg/32/795_2.png) [@rossberg](https://forum.dfinity.org/u/rossberg)\
**Post date:** [December 27, 2023, 5:41pm UTC](https://forum.dfinity.org/t/cannot-use-self-before-self-has-been-defined/25933/2 "2023-12-27T17:41:36Z")

</div>

I believe the problem is that the actor is invoking `setCheckCyclesWalletTimer` as part of its initialisation code (line 419), which passes the function `checkCanisterWalletBalance` to `Timer.setTimer`. That function, however, when called, ultimately ends up trying to call `getTreasuryAccount`, which needs `Self`. And Motoko cannot know what `Timer.setTimer` is doing with the function it’s given, conservatively it must assume that it might try to call it right away, which would hit the incompletely initialised `Self`.

So you’ll need to stage the initialisation of the timer somehow to resolve this.

---

<div class="post-metadata">

**Author:** ![jamesbeadle](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jamesbeadle/32/10110_2.png) [@jamesbeadle](https://forum.dfinity.org/u/jamesbeadle)\
**Post date:** [December 27, 2023, 5:45pm UTC](https://forum.dfinity.org/t/cannot-use-self-before-self-has-been-defined/25933/3 "2023-12-27T17:45:18Z")

</div>

You are a legend.

Yeah I just need to initialise that through a function, I really appreciate the assist.
