rand program updated by Naveen