modified : rand generator