added a rand function