modified the regex and changed i into j (because the for loop was quitted because of changings in i)