fixing random generation