Add rand function to generate random numbers