fix logic reversal