Fix bug in occurance iteration