fix iterative version