Fixed sampling of n; added parallelization scheme