Fixed logic bug with NOT