Split rogue if statement into two.

It was testing whether the value was in bounds, but it was still trying to access the data for the rest of the if statement. This wouldn't happen in C.