Working version after fixing some bugs in the parallel step