This with gosub, return.... not work well. The same again. What about putting in While loop another loop who checking the same condition and if it is not, go to this loop again until real state shows, and then go to another operation. All this inside this begin while....wend loop.
I tried to put petlja1 and petlja2, after wend... and also after buttons goto begin, and after second timer on, it goes off and on immediately, and again from the begining.

I`ll try another couple of combinations, and let you know tommorow about it.

Thanks for helping me .

Best regards.