Fixing issue with iterator