Labels enc bugfix2

I tested the solution proposed by Eric and prepered this new pull request.
I think I can merge to github-main by my self...