Added rand function