removed old code
improved random number generation