Weird loop behaviour

I have a problem modifying the Discogs script, maybe someone has a solution for this:

if I add into the trackloop another loop for credits (extraartists), similar to the one for "Artists", the loop for the current track brakes and I get weird results, like the album title instead of the track title.

The added loop looks like this:

json_foreach "tracklist"
    json_select "type_"
    if "track"
        #CREDITS
        outputto "Credits"
        json_select_many "extraartists" "name" "; "
        ifnot ""
            json_foreach "extraartists"
                DO_SOME_STUFF (like say "xxx")
            json_foreach_end
        endif
        say "|"

        #TRACKS
        ...
        #ARTIST
        ...
    endif
json_foreach_end

Like they can't be 2 json_foreach loops at the same time inside the track loop. If I comment out the entire "Artist" loop then the "Credits" loop works. As a workaround I created an entire new trackloop at the end which is a bit ugly but it works.
Anyone has an idea?