added rand function