perfectly working parallel version