hold last sensor value

Its a remain from previous iterations. Does it matter?

If it doesn't do anything useful, delete it. It doesn't hurt anything, but it takes time to compile every time, it takes time to upload every time, and it takes up space every time.

This what always confuses me. the logic of if's and else's. I cant figure it out

Else is used when there is something to do if the if statement is false.

If the switch pin is HIGH, turn the LED on. Else, turn it off. The pin can only be HIGH or LOW. There is no possibility of HALFWAYHIGH or NOTQUITELOW.

In the other hand, the values from an analog pin might fall into ranges that you want to treat as LOW, NOTQUITELOW, HALFWAYHIGH, and HIGH

int val = analogRead(somePin);
if(val <= 250)
{
}
else if(val <= 500)
{
}
else if(val <- 750)
{
}
else
{
}

Here, once an if (or else if) evaluates to true, and a block is executed, the rest of the else ifs are skipped, as is the else. If none of the if (or else if) statements are true, the else block will be executed.