modified rand code