fix an overflow bug in the MPI implementation