Fixed strange problem due to reusing iterator accidently.