Glad you got it to work...
If you're still going to try using "my" code (still can't believe I've got my own code
.)
Be careful that you don't try to random a number lower then the repeating value.
This will cause an infinite loop and will crash your messenger...
(You're right cookie that the loop thingy is a big disadvantage...)
The best thing to do is sticking to cookies code