[SOLVED]I need help with my script. I'm trying to move my treasure chest and when it goes past my ship have it reset to the front of the ship

pc.script.attribute('speed','number',5);

pc.script.create('entitymover', function (app) {
    //Creates a new Entitymover instance
   var Entitymover = function (entity) {
       this.entity = entity;
       
   };

   Entitymover.prototype = {
        //Called once after all resources are loaded and before the first update
       initialize: function () {
           this.startPos = this.entity.getPosition();
           this.player = app.root.findByName('Player');
       },

        //Called every frame, dt is time in seconds since last update
       update: function (dt) {
            
            
          this.entity.translate(0,0,this.speed*dt);
          console.log(this.entity.getPosition().z);
          
          if(this.entity.getPosition().z > 10){
              this.entity.setPosition(this.startPos);
          }
            
            
       }
   };

   return Entitymover;
});

change:
this.startPos = this.entity.getPosition();

to:
this.startPos = this.entity.getPosition().clone();