found a problem with nested for loops