iterator logics corrected