Fix incorrect iterator comparison