The logic is wrong, not just the if statement.

Ironically, correcting the if statement may give the correct result for the particular case, but the code will be wrong.

A good idea is to also...