Thank Ashley for answering me, finally solved my problem. Because the random numbers sometime duplicated and the play sound condition only trigger once so it make loop seem longer on each run. About the tries variable, forgot to set static to it so it will reset when a number is generated. This is not a bug but a mistake, thread can close. :D
Best regard.