 
 void applyProfile() {
   currentFrameIndex = 0;
-  loadFrame(currentFrameIndex);
-
-}
-
-void loadFrame(uint8_t index) {
+  loadNextAnimationStep();
+
+}
+
+void loadNextAnimationStep() {
+  //increase frame
+  currentFrameIndex++;
+  
+  //Free arrays to gain RAM
+  if(stepR != NULL) {
+    free(stepR);
+    free(stepG);
+    free(stepB);
+    
+  }
+
+  //Load current Frame;  
+  struct Frame* frame = NULL;
+  struct ColorStop** colorStops = NULL;
+  loadFrame(0, &frame, &colorStops);
+  
+  /*
+  Serial.println("-------------------");
+  Serial.print("colorStopCount: ");
+  Serial.println(frame->colorStopCount);
+  Serial.print("transitionTime: ");
+  Serial.println(frame->transitionTime);
+  Serial.print("pauseTime: ");
+  Serial.println(frame->pauseTime);
+  Serial.print("colorStops[0]->ledIndex: ");
+  Serial.println(colorStops[0]->ledIndex);
+  Serial.print("firstColorStop->r: ");
+  Serial.println(colorStops[0]->r);
+  Serial.print("firstColorStop->g: ");
+  Serial.println(colorStops[0]->g);
+  Serial.print("firstColorStop->b: ");
+  Serial.println(colorStops[0]->b);
+  Serial.print("colorStops[1]->ledIndex: ");
+  Serial.println(colorStops[1]->ledIndex);
+  Serial.print("firstColorStop->r: ");
+  Serial.println(colorStops[1]->r);
+  Serial.print("firstColorStop->g: ");
+  Serial.println(colorStops[1]->g);
+  Serial.print("firstColorStop->b: ");
+  Serial.println(colorStops[1]->b);
+  */
+  
+}
+
+void loadFrame(uint8_t index, struct Frame** framePointer, struct ColorStop*** colorStopsPointer) {
   uint8_t i;
-  
-  //Create a Frame struct if not allocated
-  if(currentFrame == NULL) {
-    currentFrame = (struct Frame*) malloc(sizeof(struct Frame));
-    currentFrame->transitionTime = 0;
-    currentFrame->pauseTime =      0;
-    currentFrame->colorStopCount = 0;  
-  
-  }
-  
-  uint8_t availableColorStops = currentFrame->colorStopCount;
-  
+
+  //If there is no frame at the pointed address, override create a new one and save it to the pointer
+  if(*framePointer == NULL) {
+    *framePointer = (struct Frame*) malloc(sizeof(struct Frame));
+    (*framePointer)->colorStopCount = 0;
+  
+  }
+ 
+  //Save simple pointer to frame
+  struct Frame* frame = *framePointer;
+
   //Init Frame address with the porfile start
   uint16_t frameAddress = EEPROM_CURRENT_PROFILE_START;
-  
+
   //Iterate over all Frames until the desired one
   for(i=0; i<index; i++) {
     //Read how many ColorStops the Frame contains and multiply it by the size of one ColorStop, add it to Address

  //show the gradient
  strip->setBrightness(64);
  strip->show();
  
  //Create arrays
  startR = (uint8_t*) malloc(ledCount);
  startG = (uint8_t*) malloc(ledCount);
  startB = (uint8_t*) malloc(ledCount);
  stepR = (uint8_t*) malloc(ledCount);
  stepG = (uint8_t*) malloc(ledCount);
  stepB = (uint8_t*) malloc(ledCount);

  //Load current profile
  applyProfile();

  
  //frameAddress is now the address of the desired Frame
  //Read the values
  frame->transitionTime = EEPROM.readInt(frameAddress);
  frame->pauseTime =      EEPROM.readInt(frameAddress+2);
  frame->colorStopCount = EEPROM.read(frameAddress+4);  
  
  if(*colorStopsPointer == NULL) {
    struct ColorStop** array =  (struct ColorStop**) malloc(sizeof(struct ColorStop) * frame->colorStopCount);
    *colorStopsPointer = array;
  
  }  
  
  struct ColorStop** colorStops = *colorStopsPointer;
  
  //Load ColorStops
  for(i=0; i<frame->colorStopCount; i++) {
    colorStops[i] = (ColorStop*) malloc(sizeof(struct ColorStop));
    loadColorStop(i, frameAddress,  colorStops[i]);
       
  }
}

