Robin2:
Don't use two separate reads in an if/else combination. The second one might give a different answer and cause all sorts of strange behaviour.
To generalize this principle, any time a condition may change over time, it is best to read the condition once and store the result, then do conditional tests on the variable. The most obvious example of this is millis(), which is constantly changing every millisecond.
if (millis() > testVar + 1000)
// do something
else if (millis() > testVar + 2000)
// do something else
That is bad because millis() will have advanced between the if() and the else() check, and so there are cases that might "slip through" the logic. Better to do:
unsigned long now = millis();
if (now > testVar + 1000)
// do something
else if (now > testVar + 2000)
// do something else