created ocurrences and indexes function to array