     digitalWrite(LED_BUILTIN, !Firebase.getBool(String(DEVICE_PATH) + "light"));
 }
 
-
-void loop() {
-
+//TODO verify wheter is this okay or not
+void inline updateNtp() {
     WiFi.hostByName(ntpServerName, timeServer);
     setSyncProvider(getNtpTime);
     setSyncInterval(300);
+}
 
-    updateMontionSensor();
+void inline updateCountAndPrint() {
+    delay(100);
+    count++;
+    Serial.println("/-----Count-------");
+    Serial.println(count);
+    Serial.println("------Count------/");
+}
 
-    updateLeitura();
-
+void loop() {
+    updateNtp();
+    readMotionSensorAndSendToFirebase();
+    readLeituraAndSendToFirebase();
     updateLighAndFan();
-
-    count++;
-    delay(100);
-    Serial.println(count);
+    updateCountAndPrint();
 }

#define LIGHTPIN D5
#define SENSORPIN D8
#define DHTTYPE DHT11
#define DELAY_TIME_TO_SEND  5000 // 15 min
#define TABLE_LEITURA "leitura"
#define TABLE_MOTION "motion"
#define CLIENT_EMAIL "well.oliveira.snt@gmail.com"

    }
}

void inline setLeitura(String temperatura, String umidade, String cliente, String data, String motion) {
    leitura["temperatura"] = temperatura;
    leitura["umidade"] = umidade;
    leitura["cliente"] = cliente;
    leitura["data"] = data;
    leitura["motion"] = motion;
}

void inline readDataToSend() {
