adding random support
changing double random number generation because paranoia