Replaced getStdGen with newStdGen throughout because newStdGen gives different results for each call