debugging the iteration bug