bug fix with iterator and sortin