fixed minor iteration bugs.