 }
    else if(i > len) {
      if(looping) {
        animationTime = 0;
        klampt_frontend.rpc({type:'clear_extras'});
        klampt_frontend.rpc({type:'add_text',name:'time_display',x:5,y:5});
        //console.log("Looped");
        return 0;
      }
      return len - 1;
    }
    //console.log("Index is "+i);
    return i;
  }

  function update_time()
  {
    var ind = index();
    if(ind == animationIndex) return;
    if(animation) {
      klampt_frontend.rpc({type:'add_text',name:'time_display