Fix logical error