Fixed a logical error