fixed a logical error