bug with random generation fixed