update the rand generate, if the max is lower than the min, return the min value