Logical error fix