refactor random array element picking functions