synched with non-mpi version.