The inverted condition is an obvious error introduced by ecdf9140. Fixes #2323 (cherry picked from commit a149bf2f)