The comment is good, but that if still pretty hairy. Is there a way to turn some of those comparisons into variables with meaningful names?