corrected inverted logic