When creating the following function, in order to get a correct answer I have to add "count-=1" line, otherwise the answer gets skewed by 1. 

```
public int countCTG(String dna) {
    int count = 0;
    int firstOccurrence = dna.indexOf("CTG");

    if (firstOccurrence != -1) {
        count +=1;
        while (dna.indexOf("CTG", firstOccurrence) != -1 && firstOccurrence != -1) {
            count +=1;
            firstOccurrence = dna.indexOf("CTG", firstOccurrence+3);
        }
        count -=1;
    }
    else {
        count = 0;
    }
    return count;
}

```

I managed to get this function working, however could you please help me understand the logic behind it? The count variable was initialized originally to 0 and if a string,for example, contains one instance of "CTG" it will be already counted in by "count +=1" line. Wouldn't count -=1 reset this variable back to 0?