Consider this function :

```
float get_geoDistance(String G1, String G2) {
int startSearch = 0;
String LAT, LON;
float lat1, lon1, lat2, lon2;
int GGA_loc ;
G1 = G1 + "\n";
G2 = G2 + "\n";
GGA_loc = G1.indexOf("GGA", startSearch);
if (GGA_loc == -1 ){
return 0;
}
if ( GGA_loc != -1) {
int TRM_loc = G1.indexOf("\n", GGA_loc);
String extract = G1.substring(GGA_loc, TRM_loc);
LAT = split(extract, ',',2);
LON = split(extract, ',',4);
LAT.trim();
LON.trim();
lat1 = LAT.toFloat() / 100.00 * (PI) / 180.00 ;
lon1 = LON.toFloat() / 100.00 * (PI) / 180.00 ;
debug2(LAT + "; " + LON);
if (LAT != "" && LON != "") {
setLedColor(YELLOW);
sodaq_wdt_safe_delay(20); // specifically this line or the one marked below.
}
}
GGA_loc = G2.indexOf("GGA", startSearch);
if (GGA_loc == -1 ) {
GPS_usable_old = G1;
GPS_usable_old_rec = G1;
return 0;
}
if ( GGA_loc != -1) {
int TRM_loc = G2.indexOf("\n", GGA_loc);
String extract = G2.substring(GGA_loc, TRM_loc);
LAT = split(extract, ',',2);
LON = split(extract, ',',4);
LAT.trim();
LON.trim();
lat2 = LAT.toFloat() / 100.00 * (PI) / 180.00;
lon2 = LON.toFloat() / 100.00 * (PI) / 180.00;
if (LAT != "" && LON != ""){
setLedColor(YELLOW);
sodaq_wdt_safe_delay(20); // specifically this line or the one marked above.
}
}
float a = pow((sin((lat1 - lat2) / 2.0)),2);
float b = cos(lat1) * cos( lat2);
float c = pow((sin((lon1 - lon2) / 2.0)),2);
float r = 6370000;
float d = 2 * r * asin(sqrt( a + b*c)) ;
return d;
}
```

This causes the program to hang from time to time. What am doing wrong? the safe delay?? Thank you.

PS: I have seen this.

I need a way to keep the watchdog time alive for 10 minutes at least, and then reset it. Is there a way to do it?