fix stochastic calculation