I do not know what is wrong with my code. The v1 and the 2 are defined. And I do not want to copy the code of *double newStart* and the *for-loop* behind the else if because than the code will become too long.

What is a better solution

```
List<double> rangeByDistanceAtMid(double start, double end, double distance){
List<double> range = new List<double>();
if(start == end){range.Add(start); return range;}
else if(start < end){double v1 = start; double v2 = end;}
else if(start > end){double v1 = end;double v2 = start;}
double newStart = (((v2 - v1) % distance) / 2) + v1;
for(double v = newStart; v < v2; v += distance){range.Add(v);}
return range;}
```

Same code but then less compact

```
List<double> rangeByDistanceAtMid(double start, double end, double distance)
{
List<double> range = new List<double>();
if(start == end)
{
range.Add(start); return range;
}
else if(start < end)
{
double v1 = start; double v2 = end;
}
else if(start > end)
{
double v1 = end;double v2 = start;
}
double newStart = (((v2 - v1) % distance) / 2) + v1;
for(double v = newStart; v < v2; v += distance)
{
range.Add(v);
}
return range;
}
```