finished parallel version