Bug fix in iteration