Added rand code