culling objects as the move offscreen

Hi,
i have been looking into moving objects in a sine wave.
Ok, no problem now after using a piece of code from here:

http://www.youtube.com/watch?v=duYjS1AVAOE

I have attached a sprite to the code and everything is fine. The collision code/ explosion and removal is also working well.
My question is , the movement works on an enterframe listener, which repeats over and over.
What I need to know is how do I have the object destroy itself when it leaves the screen bounds and not repeat over and over.

I have tried using a display.contentwidth if statement but no joy.

local energy = display.newSprite(mySprites.sheets.energyBall, mySprites.sequences.energyBall)  
 energy:play()  
  
 energy.x = 500  
 energy.y = 100  
 energy.speed = math.random(2,6)  
 energy.initY = energy.y  
 energy.amp = math.random(20,100)  
 energy.angle = math.random(1,360)  
 energy:scale(0.75,0.75)  
 layers:insert(energy)  
  
 local params = { filter = energyCollisionFilter, friction = 0, bounce = 1, linearDamping=0.0, radius = 10, density=1 }  
 physics.addBody( energy, params )  
 energy:addEventListener("collision",energy)  
  
  
 function moveEnergy(self,event)  
  
 if self.x \< -50 then  
 self.x = 500  
 self.y = math.random(90,220)  
 self.speed = math.random(2,6)  
 self.amp = math.random(20,100)  
 self.angle = math.random(1,360)  
 else  
 self.x = self.x - self.speed  
 self.angle = self.angle + .1  
 self.y = self.amp\*math.sin(self.angle)+self.initY  
  
 end  
  
 end  
 energy.enterFrame = moveEnergy  
 Runtime:addEventListener("enterFrame", energy)  
  

thank you [import]uid: 127675 topic_id: 36194 reply_id: 336194[/import]