Ok it's time for ask for help. After few hours of work I have this. I think something wrong with my trying create algorithm to solve situation when this tag is a little mess. (line 68-74). Maybe it possible way when I could repair this program. Am I long for good solution? I feel I'm close to do this.