fix random generation