This does two assignments and three comparisons in a single `if` statement, which is a lot. I don't know if there's a better way to refactor this, but I would like to open the discussion on this.