Fixed logical error