added rand func