fixed a bug in iterator