After effects position expression issue I'm trying to make clouds move out of frame and than appear again from the other side.

var vel = 100;
var pInit = position.valueAtTime(0)[0]; // initial position of a cloud
var tInit = (thisComp.width-pInit)/vel; // time it takes to cross the right border starting from init position
var tFull = (thisComp.width+width)/vel; // time it takes to cross the frame starting behind the left border
var offset = 0;
tBound = tInit;

if(time &gt; tBound) {
  tBound += tFull;
  offset += thisComp.width+width;
}

[value[0]+time*vel-offset,value[1]]


First time if statement works as expected. tBound becomes 40s and it offsets cloud. But when time gets bigger than 40 nothing happens. Neither offset variable gets bigger nor tBound. If statement doesn't work anymore. What's the problem here?
I don't think you need an expression to achieve this.  You could just loop a cloud moving across the screen inside a precomp.