Fixing a logical error