1) There are two different options. One, is to have the stops loop in a circle so they go in the order of 1,2,3,4,5,6,1,2... etc. To achieve this, you can have:


if(stopfrom > stopto)
{
...