minor fix adding random to if block