fixed iteration bug