corrected model function to include demographic stochasticity