please increment `ran` in this function.