some changes of my own (including parallelization)