# calling function with callback inside update

I am using cocos creator with typescript to make a game. The problem I am facing is weird. check out the following code :

 update(dt)
{
if(this.simulating)
{
this.dodgeTimeElapsed -= dt;
if(this.dodgeTimeElapsed < 0)
{
//!ATTENTION TO THIS PART
this.enemy.dodge(()=>{
this.dodgeFinished = true;
});
}

if(this.attackFinished && this.dodgeFinished && this.callback)
{
this.callback();
this.callback = this.player = this.enemy = null;
this.simulating = false;
}

}
}


in the attention part I am registering a callback which will get called when the action will be finished. The problem is the function in getting executed every frame with update function even if the this.simulating is false. Its supposed to called only once right? What am I doing wrong here? Thanks.