code execute loadcell value fast before getting intended weight

Hello guys, I want if function to run when weight is > than 10kg, loadcell reading is slow that when greater that 10kg weight is put on the scale if function becomes false (loadcell reading starts from lower numbers).

my purpoose is to reset scale to zero when weight < 5 is put on scale
Thanks for your time

#include "HX711.h"

HX711 scale;

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 Demo");
  Serial.println("Initializing the scale");
  // parameter "gain" is ommited; the default value 128 is used by the library
  // HX711.DOUT  - pin #A1
  // HX711.PD_SCK - pin #A0
  scale.begin(4, 5);

  Serial.print("Raw ave(20): \t\t");
  Serial.println(scale.read_average(20));   // print the average of 20 readings from the ADC

  // Scale factor:
  // 1Kg cell: 2020 for reading in gms2226.51
  // 50kg cells: 19150 for reading in kg
  scale.set_scale(2226.f);                      // this value is obtained by calibrating the scale with known    weights; see the README for details
  scale.tare();               // reset the scale to 0

  Serial.println("\nAfter setting up the scale:");

  Serial.print("Raw: \t\t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("Raw ave(20): \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("Raw ave(5) - tare: \t");
  Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("Calibrated ave(5): \t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided
  // by the SCALE parameter set with set_scale
  Serial.println("\nReadings:");
}

void loop() {
  int  i, n, T;
  unsigned long  k, s;
  unsigned long  y = 5000;
  double val, weight, sum, sumsq, mean, g1;
  n = 5;

  i = sum = sumsq = 0;
  while (i < n) {
    val = ((scale.read() - scale.get_offset()) / scale.get_scale());;
    sum += val;
    sumsq += val * val;
    i++;
  }

  mean = sum / n;

  if (mean > 1 )
  {
    delay(5000);
    weight = mean;
  }

  if ( weight < 5 )
  {
    scale.tare();
  }
  Serial.print(" mean :\t");
  Serial.println(weight, 3);

  if ( weight > 10)
  {
    Serial.print(" weight :\t");
    Serial.print(weight, 3); Serial.println("\t");
    delay(500);
    
  }
  

}

Why not sample at the same rate and simply skip readings when the weight is low. The sample rate should not be affected by the sample speed as long as it is in specification. That would be relatively easy to scale. You could accomplish the same thing with a counter and only save the reading on a certain increment of the counter.

Thanks for reply, can please show me in code, I haven’t understood