Added random/optimal option