fixed error when rand.v=NULL