Bad allocation error, fix the logic of the occurrences counter because that is where it is breaking.