Rewrite randomElement to use randomElements