     double nextStepX = player->dirX * STEP_SIZE;
     double nextStepY = player->dirY * STEP_SIZE;
 
-  if (pgm_read_byte(&level_map[int(player->y)][int(player->x + nextStepX)]) == 0) {
-      player->x += nextStepX;
-   }
-
-  if (pgm_read_byte(&level_map[int(player->y + nextStepY)][int(player->x)]) == 0) {
-      player->y += nextStepY;
-   }
-    // D(Serial.print("palyer x,y"));
-    // D(Serial.print(player->x));
-    // D(Serial.print(","));
-    // D(Serial.println(player->y));
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
+    if (pgm_read_byte(&level_map[int(player->y)][int(player->x + nextStepX)]) == 0) {
+        player->x += nextStepX;
+     }
+
+    if (pgm_read_byte(&level_map[int(player->y + nextStepY)][int(player->x)]) == 0) {
+        player->y += nextStepY;
+     }
   }
 
   if (digitalRead(LEFT_BUTTON) == 0) {
     rotatePlayer(player, LEFT);
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
   }
 
   if (digitalRead(RIGHT_BUTTON) == 0) {
     rotatePlayer(player, RIGHT);
-    display.clearDisplay();
-    doRayCasting(player);
-    display.display();
   }
 }
 

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <avr/pgmspace.h>

#define D(x)


  doRayCasting(&player);
  display.display();
  while (1) {
    if (timer_flag) {
      display.clearDisplay();
      movePlayer(&player);
      doRayCasting(&player);
      display.display();
      timer_flag = 0;
    }
  }
}

void timer_IRQ(){
  timer_flag = 1;
}

void rotatePlayer(Player *player, uint8_t right) {
