fixed logical error