added ndim argument in the simulate method