fix rand_num undefined bug