for the random part.. maybe a timer?

with a random internal? so that it calls a function at random times?

(the function being the random attaching of your barrier?)