classic logical bug