optimize the way of generate the rand arr