In reply to nocsmsourabh:
an object of t has to exist before it can be randomized; create it in the new function of trans2.