fixed random generator bug