random number generation restored; improved speed with index