added more inputs to stochastic function