Fixed rand function!