Two Arduino nanos, Two different timings

Hi, im running the same code on two different arduino nanos.

Nano 1 - runs the code as expected, every second (give or take say 50 milliseconds)

Nano 2 - takes aprox 17326 milliseconds

any ideas why this would happen?

i have some of it with comments....

#include "Wire.h" // For I2C
#include "LCD.h" // For LCD
#include "LiquidCrystal_I2C.h" // Added library*
#define THERMISTORPIN A2 // tempsense 1
#define THERMISTORPIN2 A3  // tempsense 2
#define THERMISTORNOMINAL 100000 // resistance at 25 degrees C
#define TEMPERATURENOMINAL 25 // temp. for nominal resistance (almost always 25 C)
#define NUMSAMPLES 25 // how many samples to take and average
#define BCOEFFICIENT 3950 // The beta coefficient of the thermistor (usually 3000-4000)
#define SERIESRESISTOR 100000 // the value of the 'other' resistor
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
int pwmPin     = 3; // digital PWM pin 3
int pwmVal     = 1; // The PWM Value
int blPin = 5; // backlight pin
unsigned int rpm;
float lastrpm;
float maxtemp;
float mintemp = 100;
int set = 0;
unsigned long pwmin;
unsigned int startMillis;
unsigned int timepassed;
const unsigned long period = 1000;

void setup(void) {
   startMillis = millis();
   lcd.begin(20,4);
   lcd.setBacklightPin(3,POSITIVE);
   lcd.setBacklight(HIGH);
   lcd.setCursor(0,0);
   lcd.print(String(" Duty In  ")+ char(223) + String("c Max ")+ char(223)+String("c"));
   lcd.setCursor(0,1);
   lcd.print(" ---% -----c -----c");
   lcd.setCursor(0,2);
   lcd.print(String(" RPMs Out ")+ char(223) + String("c Min ")+ char(223)+String("c"));
   lcd.setCursor(0,3);
   lcd.print(" ---- -----c -----c ");
   pinMode(pwmPin, OUTPUT);
   TCCR2A = 0x23;
   TCCR2B = 0x0A;
   OCR2A = 79;
   OCR2B = 0;
   digitalWrite(2, HIGH);
   Serial.begin(9600);
   Serial.setTimeout(10);
}

void loop(void) {
  while (millis() - startMillis >= period){
    int time = millis();
    startMillis += period;
    uint8_t i;
    float average = 0;
    float average2 = 0;
    float rpmaverage = 0;
    for (i=0; i< NUMSAMPLES; i++) {
        average += analogRead(THERMISTORPIN);
        average2 += analogRead(THERMISTORPIN2);
        pwmin = pulseIn(2, HIGH);
        rpm = (1000000 * 60) / (pwmin * 4);
        if (rpm > 2500){
          rpm = lastrpm;
        }
        lastrpm = rpm;
        rpmaverage += rpm;
    }
    average /= NUMSAMPLES;
    average2 /= NUMSAMPLES;
    rpmaverage /= NUMSAMPLES;
    average = 1023 / average - 1;
    average2 = 1023 / average2 - 1;
    average = SERIESRESISTOR / average;
    average2 = SERIESRESISTOR / average2;
    float steinhart;
    steinhart = average / THERMISTORNOMINAL;
    steinhart = log(steinhart);
    steinhart /= BCOEFFICIENT;
    steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15);
    steinhart = 1.0 / steinhart;
    steinhart -= 273.15;
    if (mintemp > steinhart){
      mintemp = steinhart;
    }
    float steinhart2;
    steinhart2 = average2 / THERMISTORNOMINAL;
    steinhart2 = log(steinhart2);
    steinhart2 /= BCOEFFICIENT;
    steinhart2 += 1.0 / (TEMPERATURENOMINAL + 273.15);
    steinhart2 = 1.0 / steinhart2;
    steinhart2 -= 273.15;
    if (maxtemp < steinhart2){
      maxtemp = steinhart2;
    }
    float averaged;
    averaged = (steinhart + steinhart2) / 2; 
    if (Serial.available()){
      set = Serial.parseInt();
    }
    if (set > 100){
      set = 100;
    }
    serialFlush();
    if (set > 25){
       OCR2B = set;
    }else{
      set = 0;
      if (averaged < 25){
        OCR2B = 25;
      }else if (averaged < 55){
        OCR2B = averaged;
      }else{
        OCR2B = 100;
      }
    }
    lcd.setCursor(1,1);
    if (OCR2B < 100){
      lcd.print(" ");
    }
    lcd.print(OCR2B + String("% ") + steinhart2 + String("c ") + maxtemp + String("c "));
    lcd.setCursor(1,3);
    if (rpmaverage < 1000){
      lcd.print(" ");
    }
    lcd.print(String(rpmaverage,0) + String(" ") + steinhart + String("c ") + mintemp + String("c "));
    Serial.print(String("Temp In: ")+steinhart2+String("c "));
    Serial.print(String("Max Temp: ")+maxtemp+String("c "));
    Serial.print(String("Temp Out: ")+steinhart+String("c "));
    Serial.print(String("Min Temp: ")+mintemp+String("c "));
    Serial.print(String("RPM: ")+String(rpmaverage,0)+String(" "));
    Serial.println(String("Duty: ")+(OCR2B)+String("% ")); 
    timepassed = millis() - time;
    Serial.println(String("time passed: ")+timepassed); 
  }

}
void serialFlush(){
  while(Serial.available() > 0) {
    char t = Serial.read();
  }
}

Well after replacing every wire, using a different usb lead i managed to get second one working as expected apart from after its been on for over a minute, then it just runs the code flat out instead of every 1000 milliseconds

I have experienced that i had made a bad soldering connection on the header-pins connected to a Nano (or a Pro-mini) Just going over them quickly and remelting those spot may help a bit.