Fixed a race condition in the parallel version