This might be better as `!=` instead of `not if`.  I'm not sure about what the preferred coding style is.