Fix chained comparions: remove redundant comparisons