writing parallel version