fix logical error