fixing random generator...adding while loop