ok, ich konnte den Code optimieren, er macht jetzt was er soll.

Danke.