parallelization almost done, but not yet tested