Fix invalid logic