                 if counter1 == wordsListSize {
                     result.append(counter2)
                     s2 = s![counter2..<counter2+wordLength]
-                    dict2[s2]!--
-                    counter1--
+                    dict2[s2]! -= 1
+                    counter1 -= 1
                     counter2 += wordLength
                 }
+                j += wordLength
             }
             dict2.removeAll(keepCapacity: false)
         }

                    } else {
                        dict2[s1]! += 1
                    }
                    counter1++
                } else {
                    s2 = s![counter2..<counter2+wordLength]
                    while s2 != s1 {
                        dict2[s2]!--
                        counter1--
                        counter2 += wordLength
                        s2 = s![counter2..<counter2+wordLength]
                    }

        var s2: String
        var counter1: Int
        var counter2: Int
        for i in 0 ..< wordLength {
            counter1 = 0
            counter2 = i
            var j = i;
            while j < stringLength {
                s1 = s![j..<j+wordLength]
                if dict1[s1] == nil {
                    dict2.removeAll(keepCapacity: false)
