fix end of iteration