chooseIndex and chooseRandom helpers