code generates 99.9 percent correctly